/* 
 * File:   MetaInfo.cpp
 * Author: Guilherme Monteiro
 * 
 */

#include "../headers/MetaInfo.h"


/**
 * Construtor of class.
 * 
 * @param imagePath: image path received of entry
 * 
 */
MetaInfo::MetaInfo() {
    pathValidator = new PathValidator();
}

MetaInfo::MetaInfo(const MetaInfo& orig) {
}

MetaInfo::~MetaInfo() {
}

/**
 * Returns the high resolution image path.
 * 
 * @return highResolutionImagePath
 */
string MetaInfo::getHighResolutionImagePath() {
    return this->highResolutionImagePath;
}

/**
 * Configures the high resolution image path.
 */
void MetaInfo::setHighResolutionImagePath() {
    this->highResolutionImagePath = ".." + BOOKS + getBookName() + ALTA_RESOLUCAO + adaptPageName(getPageName());
    //printf("high path: %s\n", highResolutionImagePath.c_str());
}

/**
 * Configures the low resolution image path.
 */
void MetaInfo::setLowResolutionImagePath() {
    this->lowResolutionImagePath = ".." + BOOKS + getBookName() + BAIXA_RESOLUCAO + adaptPageName(getPageName());
    //printf("low path: %s\n", lowResolutionImagePath.c_str());
}

/**
 * Returns the low resolution image
 * path.
 * 
 * @return lowResolutionImagePath
 */
string MetaInfo::getLowResolutionImagePath() {
    return this->lowResolutionImagePath;
}

/**
 * Returns the page name.
 * 
 * @return page name
 */
string MetaInfo::getPageName() {
    return this->pageName;
}

/**
 * Returns the book name.
 * 
 * @return book name
 */
string MetaInfo::getBookName() {
    return this->bookName;
}

/**
 * Configures the book name.
 * 
 * @param name
 */
void MetaInfo::setBookName(string name) {
    this->bookName = name;
}

/**
 * Configures the page name.
 * 
 * @param name
 */
void MetaInfo::setPageName(string name) {
    this->pageName = name;
}

/**
 * Adapt page name in the case that
 * it have one '_' to keep without '_' and
 * without index of ROI.
 * 
 * 
 * @param pageName
 * @return pageName modified
 */
string MetaInfo::adaptPageName(string pageName) {
    string result;
    if(count(pageName.begin(), pageName.end(), '_') == 1) {
        int i = 0;
        while(pageName[i] != '_') {
            result += pageName[i++];
        }
        result += ".png";
        return result;
    }
    else {
        return pageName;
    }
    
}